import http from "@/common/http";
import {CategoryItem} from "@/common/interfaces/category";
import categoryListResponse from "@/apis/mock/category.json";

export async function queryCategory(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(categoryListResponse)
  }
  return http('/api/product/category/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeCategory(params: { ids: number[] }) {
  return http('/api/product/category/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addCategory(params: CategoryItem) {
  return http('/api/product/category/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateCategory(params: CategoryItem) {
  return http('/api/product/category/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
